# MONGODB_DATABASES = {
#     'name': 'cmdb',  # 未来数据库中的库名字
#     # 'username': 'wayne',
#     # 'password': 'wayne',
#     'host': '127.0.0.1',
#     'port': 27017,
#     'tz_aware': True
# }
# from mongoengine import connect
#
# connect(**MONGODB_DATABASES)  # _connections
# #####################
# ODM操作
from cmdb.models import CiType, CiTypeField

# ct = CiType()
# ct.name = "Network Interface"
# ct.label = "网络接口"
# # ct.version = 1
# ct.fields = [
#     CiTypeField(name='name', label="名称", type="str", required=True),
#     CiTypeField(name='IP Address', label="IP地址", type="str", required=True),
#     CiTypeField(name='Mask', label="掩码", type="str", required=True),
#     CiTypeField(name='Mac Address', label="MAC", type="str"),
#     CiTypeField(name='Gateway', label="网关", type="str"),
# ]
# ct.save()
# print(ct)

# ct = CiType()
# ct.name = 'Server'
# ct.label = '服务器'
# ct.version = 1
# # 服务器属性字段太多，省略一些，完成核心功能
# ct.fields = [
#     CiTypeField(name='name', label='资产名称', type='str', required=True),
#     CiTypeField(name='Asset number', label='资产编号', type='str'),
#     CiTypeField(name='Brand', label='品牌', type='str'),
#     CiTypeField(name='Model', label='型号', type='str'),
#     CiTypeField(name='OS Family', label='操作系统', type='str'),
#     CiTypeField(name='OS Version', label='OS版本', type='str'),
#     CiTypeField(name='Management IP', label='管理IP', type='str'),
#     CiTypeField(name='CPU', label='CPU', type='str'),
#     CiTypeField(name='RAM', label='内存', type='str'),
#     CiTypeField(name='Rack', label='机架', type='str'),
#     CiTypeField(name='Production Date', label='上线时间', type='date'),
#     CiTypeField(name='Purchase date', label='购买日期', type='date'),
#     CiTypeField(name='End of warranty', label='保修期结束', type='date'),
#     # 可以有N个网络接口，一对多
#     CiTypeField(name='Network Interface', label='网络接口', type='list:Network Interface'),
# ]
# ct.save()